/**
 类

 创建一个 User 类，它带有一个构造函数和一些公共字段
 类的字段包含了接口所需要的字段，所以他们能很好的兼容
 */
class User {
    fullName: string
    firstName: string
    lastName: string

    constructor (firstName: string, lastName: string) {
        this.firstName = firstName
        this.lastName = lastName
        this.fullName = firstName + ' ' + lastName
    }
}

interface Person {
    firstName: string
    lastName: string
}

function greeter (person: Person) {
    return 'Hello, ' + person.firstName + ' ' + person.lastName
}

let user = new User('Yee', 'Huang')

console.log(greeter(user))
